package com.leezt.designpattern.creation.s01singleton;

import java.util.concurrent.atomic.AtomicLong;

/*
 * implement ID generator with hungry way.
 */
public class HungryIdGenerator {
    private final AtomicLong id = new AtomicLong(0);
    private static final HungryIdGenerator instance = new HungryIdGenerator();
    private HungryIdGenerator(){}
    public static HungryIdGenerator getInstance() {
        return instance;
    }

    public long getId() {
        return id.incrementAndGet();
    }
}
